package hjt.com.module_test.adpter;

import android.content.Context;

import com.tong.lib.adapter.recyclerview.CommonAllAdapter;
import com.tong.lib.adapter.recyclerview.base.ViewHolder;

import java.util.Collections;
import java.util.List;

import hjt.com.module_test.R;
import hjt.com.module_test.widget.ItemTouchMoveListener;

/**
 * Created by hjt on 2019/3/21.
 */

public class TestAdpter extends CommonAllAdapter<String> implements ItemTouchMoveListener {
    public TestAdpter(Context context, List<String> datas) {
        super(context, datas);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.test_rlv_test;
    }

    @Override
    protected void convert(ViewHolder holder, String s, int position) {
        holder.setText(R.id.tv, s);
    }

    @Override
    public void onMove(int fromPosition, int toPosition) {
        Collections.swap(mDatas, fromPosition, toPosition);
        notifyItemMoved(fromPosition, toPosition);
    }

    @Override
    public void onSwipe(int position) {
        mDatas.remove(position);
        notifyItemRemoved(position);
    }
}
